package com.sso.shiro;

import com.sso.common.enums.SysResourceEnum;
import com.sso.entity.SysResource;
import com.sso.manager.SysResourceManager;
import com.tools.util.StrUtils;
import org.apache.shiro.web.util.WebUtils;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

public class HttpUrlAccessFilter {
    private SysResourceManager resourceManager;

    public boolean isUrlAccess(ServletRequest request){
        HttpServletRequest httpRequest = WebUtils.toHttp(request);
        String url = httpRequest.getServletPath();
        SysResource resource = resourceManager.selectByURL(url);
        if(StrUtils.isEmpty(resource.getId())){
            return true;
        }else if(SysResourceEnum.status.DEL.key.equals(resource.getStatus())){

        }else if(SysResourceEnum.status.STOP.key.equals(resource.getStatus())){

        }else{

        }
        return true;
    }
}
